<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>留存支付次数配置列表</title>
<@fm.header />
<script>
$(document).ready(function(){
	var date=new Date;
	var year=date.getFullYear(); 
	var month=date.getMonth()+1;
	month =(month<10 ? "0"+month:month); 
	
	$('#date').val(year + "-" + month);
});

function doSearch(){    
    $('#tt').datagrid('load', {    
        mark: $('#mark').val()
    });
}

function config(){
	var rows = $('#tt').datagrid('getSelections');
    if (rows.length > 0){
    	$('#dlg').dialog('open');
    } else {
    	showMsg(market.content.title, market.content.tips, alert);
    }
}

function save() {
	var marks = [];
	var rows = $('#tt').datagrid('getSelections');
	for(var i=0; i<rows.length; i++){
    	marks.push(rows[i].mark);
	}
	
	var date = $('#date').val();
	var num = $('#num').val();
	
	$.ajax({
	    url:'/retent/pay/configNum',
	    type:'POST',
	    data:{
	        marks : marks.join(","),
	        date : date,
	        num : num
	    },
	    async:true,
	    dataType: 'json',
	    success:function(data,textStatus,jqXHR){
	    	$('#num').val("");
	    	$('#dlg').dialog('close');
	    	$('#tt').datagrid('reload');
	    },
	    error:function(xhr,textStatus){
	    }
	})
}

function cancel() {
	$('#dlg').dialog('close');
}

</script>
</head>
<body class="cmp-list-body">
<div id="tb" style="padding:3px">
    <span>Mark:</span>
    <input id="mark" style="line-height:20px;border:1px solid #ccc">
    
    <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="doSearch();">查询</a> 
    
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="config();">设置次数</a>
</div>
<table id="tt" class="easyui-datagrid" title="留存支付次数配置列表" iconCls="icon-save" 
	url="/retent/pay/listJson" toolbar="#tb" rownumbers="true" idField="mark"
	pagination="true" fitColumns="true" pageSize="15" pageList="[15,30,60,80,100]"> 
    <thead>
        <tr>
        	<th align="center" width="2%"  field="mark" data-options="checkbox:true"></th>
        	<th align="center" width="35%" field="apkName">名称</th>
            <th align="center" width="25%" field="date">月</th>
            <th align="center" width="10%" field="num">次数</th>
        </tr>
    </thead>   
</table>

<div id="dlg" class="easyui-dialog" title="设置次数" data-options="iconCls:'icon-save',closed:'true'" style="width:400px;height:200px;padding:10px">
	<table>
        <tr>
            <td><label for="date">月度:</label></td>
            <td><input class="easyui-validatebox" type="text" id="date" name="date" data-options="required:true"></input></td>
        </tr>
        <tr>
            <td><label for="num">次数:</label></td>
            <td><input type="text" class="easyui-validatebox" id="num" name="num"/></td>
        </tr>
	 </table>
	 <div region="south" border="false" style="text-align: center; padding: 5px 5px 5px 0;">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="save();">保存</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="cancel();">取消</a>
	 </div>
</div>
</body>
</html>